package mysql8学习.高级.第09章_性能分析工具;

/**
 *
 * 2. JSON格式
 *   第1种格式中介绍的EXPLAIN语句输出中缺少了一个衡量执行计划好坏的重要属性一成本。
 *   而JSON格式是四种式里面输出信息最详尽的格式，里面包含了执行的成本信息。
 * ● JSON格式:在EXPLAIN单词和真正的查询语句中间加上 FORMAT=JSON。
 *
 *  使用方式: EXPLAIN FORMAT=JSON SELECT ...
 *  有些字段名字不一致，但是表达的意思是一致的
 *
 *  比如
 *  传统                  JSON
 *  id                 select_id
 *  select_type        None
 *  table              table_name
 *  partitions         partitions
 *  type               access_type
 *  possible_keys      possible_keys
 *  key                key
 *  key_len            key_length
 *  ref                ref
 *  rows               rows
 *  filtered           filtered
 *  Extra              None
 *
 *
 * explain format=json
 * select * from jobs j1 right join job_history j2
 * on  j2.employee_id = j1.job_id
 * where j1.job_id = 'AC_ACCOUNT';
 * JSON 展示案例
 *
 * {
 *   "query_block": {
 *     "select_id": 1,
 *     "cost_info": {
 *       "query_cost": "0.39"
 *     },
 *     "nested_loop": [
 *       {
 *         "table": {
 *           "table_name": "j1",
 *           "access_type": "const",
 *           "possible_keys": [
 *             "PRIMARY",
 *             "job_id_pk"
 *           ],
 *           "key": "PRIMARY",
 *           "used_key_parts": [
 *             "job_id"
 *           ],
 *           "key_length": "32",
 *           "ref": [
 *             "const"
 *           ],
 *           "rows_examined_per_scan": 1,
 *           "rows_produced_per_join": 1,
 *           "filtered": "100.00",
 *           "cost_info": {
 *             "read_cost": "0.00",   #I/O成本   = rows * (1- filter) 条记录的CPU成本
 *             "eval_cost": "0.10",   # rows * filter
 *             "prefix_cost": "0.00",
 *             "data_read_per_join": "152"
 *           },
 *           "used_columns": [
 *             "job_id",
 *             "job_title",
 *             "min_salary",
 *             "max_salary"
 *           ]
 *         }
 *       },
 *       {
 *         "table": {
 *           "table_name": "j2",
 *           "access_type": "ref",
 *           "possible_keys": [
 *             "PRIMARY",
 *             "jhist_emp_id_st_date_pk"
 *           ],
 *           "key": "PRIMARY",
 *           "used_key_parts": [
 *             "employee_id"
 *           ],
 *           "key_length": "4",
 *           "ref": [
 *             "const"
 *           ],
 *           "rows_examined_per_scan": 1,
 *           "rows_produced_per_join": 1,
 *           "filtered": "100.00",
 *           "cost_info": {
 *             "read_cost": "0.25",
 *             "eval_cost": "0.14",
 *             "prefix_cost": "0.39",
 *             "data_read_per_join": "68"
 *           },
 *           "used_columns": [
 *             "employee_id",
 *             "start_date",
 *             "end_date",
 *             "job_id",
 *             "department_id"
 *           ],
 *           "attached_condition": "(`atguigudb`.`j2`.`employee_id` = 'AC_ACCOUNT')"
 *         }
 *       }
 *     ]
 *   }
 * }
 */
public class G2_JSON格式 {
}
